package org.anyin.gitee.cloud.center.cdms.repository;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import org.anyin.gitee.cloud.center.cdms.mapper.CsWxInfoMapper;
import org.anyin.gitee.cloud.center.cdms.model.CsWxInfo;
import org.anyin.gitee.cloud.lib.core.web.BaseRepository;
import org.springframework.stereotype.Repository;

@Repository
public class CsWxInfoRepository extends BaseRepository<CsWxInfoMapper, CsWxInfo> {

    public void handleOpenidMobileUnique(String mobile, String openid, String appId){
        baseMapper.loginDelByMobileExcludeOpenid(mobile, openid, appId);
        baseMapper.loginDelByOpenIdExcludeMobile(openid, mobile, appId);
    }

    public CsWxInfo infoByMobileOpenid(String mobile, String openid, String appId){
        QueryWrapper<CsWxInfo> wrapper = new QueryWrapper<>();
        wrapper.eq("mobile", mobile);
        wrapper.eq("openid", openid);
        wrapper.eq("app_id", appId);
        return baseMapper.selectOne(wrapper);
    }
}
